package com.why.amallrest.uitl;

import cn.hutool.jwt.JWT;
import cn.hutool.jwt.JWTUtil;
import cn.hutool.jwt.JWTValidator;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: mall-parent
 * @description:
 * @author: @why
 * @create: 2021-10-30 16:53
 **/
public class RestCommonUtils {

    /**
     * 生成jwtToken
     * @param data
     * @param keyStr
     * @return
     */
    public static String generateJwtToken(Map<String, Object> data, String keyStr) {
        // 密钥
        byte[] key = keyStr.getBytes();
        return JWT.create()
                .addPayloads(data)
                .setIssuedAt(new Date())
                .setExpiresAt(new Date(System.currentTimeMillis() + 30 * 1000000))
                .setKey(key)
                .sign();

    }
}
